package com.project.springboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;

import javax.persistence.EntityManagerFactory;

/**
 * description: JPA事务配置类（Hibernate对应的事务管理器）
 * @author 朱正磊
 * @date 2025-10-23 13:49:12
 */
//@Configuration
public class JpaTransactionConfig {

    /**
     * description: 注册Hibernate对应的事务管理器（JpaTransactionManager）
     * @author 朱正磊
     * @date 2025-10-23 13:56:19
     * @return 返回JPA事务管理器
     */
    @Bean
    public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
        JpaTransactionManager transactionManager = new JpaTransactionManager();
        transactionManager.setEntityManagerFactory(entityManagerFactory);
        return transactionManager;
    }

}
